
package metadatabrowser;



import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.ViewerCell;import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

/**
 *
 * @author Seuchter
 */
public class PropertiesColumnBuilder
{

    public PropertiesColumnBuilder()
    {
    }

    private TableViewerColumn buildColumn(TableViewer viewer, String name, int index)
    {
        Table t = viewer.getTable();
        t.setHeaderVisible(true);
        final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
        final TableColumn column = new TableColumn(t, SWT.LEFT,index);
        column.setText(name);
        column.setResizable(true);
        column.setMoveable(true);
        column.setWidth(100);
        return viewerColumn;
    }

    public TableViewerColumn[] buildColumns(TableViewer viewer)
    {
       TableViewerColumn colPropName = buildColumn(viewer, "Property",1);
       TableViewerColumn colPropValue = buildColumn(viewer, "Value",2);
/*
       colPropName.setLabelProvider(new ColumnLabelProvider()
       {

            @Override
            public String getText(Object element)
            {

                if(element instanceof Pair)
                {
                    Pair<?,?> p = (Pair<?, ?>)element;
                    return p.getFirst().toString();
                }

                return "!!!ERROR!!!";
            }

       });

       colPropValue.setLabelProvider(new ColumnLabelProvider()
       {

            @Override
            public String getText(Object element)
            {

                if(element instanceof Pair)
                {
                    Pair<?,?> p = (Pair<?, ?>)element;
                    return p.getSecond().toString();
                }

                return "!!!ERROR!!!";
            }


        });

 * 
 */
        return new TableViewerColumn[]{colPropName, colPropValue};
    }
}
